package com.team.weigou;

import android.app.Application;

import com.lidroid.xutils.bitmap.BitmapGlobalConfig;
import com.lidroid.xutils.cache.MD5FileNameGenerator;
import com.team.weigou.utils.FileUtils;

public class BaseApp extends Application {
    private static BaseApp app;

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        configGlobalBitmap();
    }

    public static BaseApp getInstance() {
        return app;
    }

    public static BaseApp getApp() {
        return app;
    }

    /**
     * 图片加载框架全局配置
     * BitmapUtils
     */
    private void configGlobalBitmap() {
        BitmapGlobalConfig config = BitmapGlobalConfig.getInstance(this, FileUtils.getImageCache());
        config.setDefaultCacheExpiry(1000L * 60 * 60 * 24 * 30);
        //启用磁盘缓存
        //      config.setDiskCacheEnabled(true);
        //设置内存的大小 默认4M 最小2M
        config.setMemoryCacheSize(1024 * 1024 * 8);
        //设置磁盘的大小
        config.setDiskCacheSize(1024 * 1024 * 100);
        //设置线程池的线程数量 默认 5
        config.setThreadPoolSize(4);
        //保存图片的名字以MD5码命名
        config.setFileNameGenerator(new MD5FileNameGenerator());
    }


}
